import {ShareVideoRankDetail} from "../../../engines/services/miniGameContent/miniApp";
import O1HD from "../../../engines/gameEngine";

const {ccclass, property} = cc._decorator;

@ccclass
export default class shareVideoItem extends cc.Component {

    @property(cc.Label)
    lbNumber: cc.Label = null;
    @property(cc.Label)
    lbDiggCount: cc.Label = null;
    @property(cc.Sprite)
    spTitleImage: cc.Sprite = null;

    onLoad() {

    }

    start() {

    }

    //类型
    private m_videoObject: ShareVideoRankDetail = null;

    OnBtnPlay() {
        O1HD.getServices().miniGameSrv.getAppApiInstance().showVideo(this.m_videoObject.video_id);
    }

    //绑定
    BindVideoData(data: ShareVideoRankDetail) {
        console.log('数据', data);
        this.m_videoObject = data;
        this.lbNumber.string = `第 ${this.m_videoObject.rank} 名`;
        this.lbDiggCount.string = `${this.m_videoObject.digg_count} 赞`;
        console.log('请求图片', this.spTitleImage);
        //下
        this.scheduleOnce(() => {
            O1HD.getServices().miniGameSrv.getAppApiInstance().drawUrlImage(
                this.m_videoObject.cover_url,
                (spf: cc.SpriteFrame) => {
                    console.log('图片结果', spf, this.spTitleImage);
                    this.spTitleImage.spriteFrame = spf;
                })
        })
    }

    // update (dt) {}
}
